package com.twxm.breed.service;

import com.twxm.breed.entity.Monitor;
import com.twxm.breed.mapper.MonitorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MonitorService {
    @Autowired
    private MonitorMapper monitorMapper;


    public void setMonitor(Monitor monitor) {
        if (monitorMapper.selectByDeviceId(monitor.getDeviceInfo().getDeviceId()) == null){
            monitorMapper.setMonitor(monitor);
        }else{
            monitorMapper.updateMonitor(monitor);
        }

    }

    public Monitor getMonitorDeviceId(String deviceId) {
        return monitorMapper.selectByDeviceId(deviceId);
    }

    public List<Monitor> getMonitor() {
        return monitorMapper.getMonitor();
    }
}
